<!--
 * @Author: zhangpeng
 * @Date: 2024-11-22 10:04:34
 * @FilePath: \scientific_research_manager_web\src\components\RepulseModal\index.vue
 * @LastEditTime: 2025-01-13 11:23:57
 * @Description: 成果打回
-->

<script setup lang="ts">
const props = defineProps({
  title: {
    type: String,
    default: '打回',
  },
  visible: {
    type: Boolean,
    default: false,
  },
  maxlength: {
    type: Number,
    default: 500,
  },
})



const emit = defineEmits(['close', 'ok'])

const form = ref({
  repulseMessage: ''
})

const formRef = ref()
const rules = {
  repulseMessage: [{ required: true, message: "打回意见不能为空", trigger: "blur" }],
}

async function repulseHandle() {
  await formRef.value?.validate((valid) => {
    if (valid) {
      emit('ok', form?.value)
    } else {
      return
    }
  })
}

</script>

<template>
  <div class="repulse-modal">
    <el-dialog v-model="props.visible" :title="props?.title" width="600" @close="emit('close')" :close-on-click-modal="false" :footer="false">
      <el-form :model="form" class="pr-[20px]" ref="formRef" :rules="rules">
        <el-form-item label="打回意见" :label-width="92" prop="repulseMessage">
          <div class="w-full">
            <QuickText v-model="form.repulseMessage" :maxlength="500"  :rows="12" ></QuickText>
          </div>
        </el-form-item>

      </el-form>
      <div class="dialog-footer">
          <el-button type="primary" plain @click="repulseHandle">
            打回
          </el-button>
        </div>
      <template #footer>
        
      </template>
    </el-dialog>
  </div>
</template>

<style scoped lang="scss">


.dialog-footer {
  --at-apply: text-right;
}

.repulse-modal {
  :deep(.el-dialog__footer) {
    display: none;
  }
}
</style>